package cn.itcast.bos.service.base.impl;

import cn.itcast.bos.Dao.base.CourierDao;
import cn.itcast.bos.domain.base.Courier;
import cn.itcast.bos.service.base.CourierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.domain.Specifications;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class CourierServiceImpl implements CourierService {

    @Autowired
    private CourierDao courierDao;
    @Override
    public void save(Courier courier) {
        courierDao.save(courier);
    }

    @Override
    public Page<Courier> findPageData(Specification<Courier> specification, PageRequest pageRequest) {
        return courierDao.findAll(specification,pageRequest);
    }

    @Override
    public void delBatch(String[] idArray) {
        for (String idStr : idArray) {
            int id = Integer.parseInt(idStr);
            courierDao.updateDelTag(id);
        }
    }

    @Override
    public void doRestore(String[] idArray) {
        for (String idStr : idArray) {
            int id = Integer.parseInt(idStr);
            courierDao.doRestoreDelTag(id);
        }
    }
}
